from datetime import datetime
from rest_framework import serializers
from Stage.models import Stage
from module.serializers import ModuleSerializers


class StageSerializers(serializers.ModelSerializer):

    module_set = ModuleSerializers(many=True, read_only=True)

    class Meta:
        model = Stage
        fields = '__all__'

    def update(self, instance, validated_data):
        validated_data['update_time'] = datetime.now()  # 设置更新时间
        return super().update(instance, validated_data)